// 构建消费者
const {initConnection} = require('../util/initMq')

async function consumerDLX() {
    const testExchangeDLX = 'dram_dxl';
    const testQueueDLX = 'queue_dxl_pro';
    const testRoutingKeyDLX = 'dream_route_pro';


    // 1. 创建链接对象
    const connection = await initConnection();
    const ch = await connection.createChannel();
    await ch.assertExchange(testExchangeDLX, 'direct', {durable: true});
    const queueResult = await ch.assertQueue(testQueueDLX, {
        exclusive: false,
    });
    await ch.bindQueue(queueResult.queue, testExchangeDLX, testRoutingKeyDLX);
    await ch.consume(queueResult.queue, msg => {
        console.log('consumer msg：', msg.content.toString());
    }, {noAck: true});
}

consumerDLX();
